<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>侦听器选项参数</title>
</head>
<body>
<div id="app">
    <h1>监听 ref 类型变量</h1>
    <input type="text" v-model="info">

    <h1>侦听 reactive 类型的变量</h1>
    <div>{{ person }}</div>
</div>


<script type="module">
    import {createApp, ref, watch, reactive} from "../../../../../js/vue.esm-browser.js";

    const app = createApp({
        setup() {
            let info = ref(null)
            let person = reactive({
                name: "abcque",
                age: 18,
                gender: "M",
                socore: {
                    math: 98,
                    chinese: 90,
                    c: 100,
                }
            })
            // 默认情况下，初次加载时没有调用
            /*watch(info, (value) => {
                console.log("调用了 侦听器");
                // console.log(value);
            })*/

            // 在初次加载完毕后，执行侦听回调
            watch(info,
                (value) => {
                    console.log("调用了 侦听器");
                    // console.log(value);
                },
                {immediate: true}
            )

            watch(person,
                function (value) {
                    console.log("检测到对象内容发生了变化");
                },
                {deep: false}
            )


            return {
                info, person,
            }
        }
    })

    app.mount("#app")
</script>
</body>
</html>